package com.livestocksolutions.util;

import com.livestocksolutions.Group;

/**
 * Store a Mob or Group, that can be stored directly in a ComboBox.
 * @param <T> The Sub-Class of or Group to store in this GroupList
 *
 * @author Adam Parr
 * @.modified 16 October 2012
 */
public class GroupList<T extends Group> extends ItemList<T> {
	/**
	 * Define whether or not to 
	 */
	protected boolean removeState = false;
	
	/**
	 * Constructor
	 * @param value The Value that will be returned when this Objects toString()
	 *               method is called.
	 */
	public GroupList(String value) {
		super(value);
	}
	
	/**
	 * Constructor
	 * @param item The Group to store in this GroupList
	 * @param remove The prefix should be Remove -<tt>true</tt>, or Add -<tt>false</tt>.
	 */
	public GroupList(T item, boolean remove) {
		super(item);
		removeState=remove;
	}
	
	/**
	 * Get if this GroupList Object represents a remove all matching members <tt>true</tt>, or not <tt>false</tt>.
	 * @return <tt>true</tt> Remove, <tt>false</tt> Add.
	 */
	public boolean isRemove(){
		return removeState;
	}
	
	/**
	 * Constructor
	 * @param item The Group to store in this GroupList
	 */
	public GroupList(T item) {
		super(item);
	}

	@Override
	public String toString(){
		return (!value.equals("")?value:(removeState?"Remove ":"Add ")+(item!=null?item.getName():"All"));
	}
}
